package com.taskcollection.service;

import com.taskcollection.bean.ProjectTeamBean;
import com.taskcollection.bean.StudentBean;
import com.taskcollection.bean.StudentProjectBean;
import com.taskcollection.bean.StudentProjectTeamBean;
import com.taskcollection.mapper.ProjectTeam;
import com.taskcollection.mapper.StudentProjectTeam;
import com.taskcollection.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * Created by Administrator on 2016/8/4 0004.
 */
public class StudentProjectTeamService {
    public boolean add(StudentProjectTeamBean sptb){
        SqlSession sqlSession = MybatisUtil.getinstance().getFactory().openSession();
        try{
            StudentProjectTeam spt = sqlSession.getMapper(StudentProjectTeam.class);
            boolean flag = spt.add(sptb);
            sqlSession.commit();
            return flag;
        }finally {
            sqlSession.close();
        }
    }
    public List<StudentBean> getByProjectTeamId(String ProjectTeam_id){
        return null;
    }
    public StudentProjectTeamBean getByStudentId(String student_id){
        SqlSession sqlSession = MybatisUtil.getinstance().getFactory().openSession();
        try{
            StudentProjectTeam spt = sqlSession.getMapper(StudentProjectTeam.class);
            StudentProjectTeamBean sptb = spt.getByStudentId(student_id);
            //StudentService ss = new StudentService();
            //sptb.setStudent(ss.getById(sptb.getStudent_id()==null?"":sptb.getStudent_id()));
            //ProjectTeamService pts = new ProjectTeamService();
            //sptb.setProjectTeam(pts.getById(sptb.getProjectTeam_id()==null?"":sptb.getProjectTeam_id()));
            return sptb;
        }finally {
            sqlSession.close();
        }

    }
}
